// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyClipAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyClipAttributes
//
// Purpose:
//   This class contains attributes for the clip operator.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a ClipAttributes.
//
struct ClipAttributesObject
{
    PyObject_HEAD
    ClipAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewClipAttributes(int);
std::string
PyClipAttributes_ToString(const ClipAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    const char *quality_names = "Fast, Accurate";
    switch (atts->GetQuality())
    {
      case ClipAttributes::Fast:
          snprintf(tmpStr, 1000, "%squality = %sFast  # %s\n", prefix, prefix, quality_names);
          str += tmpStr;
          break;
      case ClipAttributes::Accurate:
          snprintf(tmpStr, 1000, "%squality = %sAccurate  # %s\n", prefix, prefix, quality_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *funcType_names = "Plane, Sphere";
    switch (atts->GetFuncType())
    {
      case ClipAttributes::Plane:
          snprintf(tmpStr, 1000, "%sfuncType = %sPlane  # %s\n", prefix, prefix, funcType_names);
          str += tmpStr;
          break;
      case ClipAttributes::Sphere:
          snprintf(tmpStr, 1000, "%sfuncType = %sSphere  # %s\n", prefix, prefix, funcType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetPlane1Status())
        snprintf(tmpStr, 1000, "%splane1Status = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%splane1Status = 0\n", prefix);
    str += tmpStr;
    if(atts->GetPlane2Status())
        snprintf(tmpStr, 1000, "%splane2Status = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%splane2Status = 0\n", prefix);
    str += tmpStr;
    if(atts->GetPlane3Status())
        snprintf(tmpStr, 1000, "%splane3Status = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%splane3Status = 0\n", prefix);
    str += tmpStr;
    {   const double *plane1Origin = atts->GetPlane1Origin();
        snprintf(tmpStr, 1000, "%splane1Origin = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane1Origin[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *plane2Origin = atts->GetPlane2Origin();
        snprintf(tmpStr, 1000, "%splane2Origin = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane2Origin[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *plane3Origin = atts->GetPlane3Origin();
        snprintf(tmpStr, 1000, "%splane3Origin = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane3Origin[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *plane1Normal = atts->GetPlane1Normal();
        snprintf(tmpStr, 1000, "%splane1Normal = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane1Normal[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *plane2Normal = atts->GetPlane2Normal();
        snprintf(tmpStr, 1000, "%splane2Normal = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane2Normal[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *plane3Normal = atts->GetPlane3Normal();
        snprintf(tmpStr, 1000, "%splane3Normal = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", plane3Normal[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    if(atts->GetPlaneInverse())
        snprintf(tmpStr, 1000, "%splaneInverse = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%splaneInverse = 0\n", prefix);
    str += tmpStr;
    const char *planeToolControlledClipPlane_names = "NONE, Plane1, Plane2, Plane3";
    switch (atts->GetPlaneToolControlledClipPlane())
    {
      case ClipAttributes::None:
          snprintf(tmpStr, 1000, "%splaneToolControlledClipPlane = %sNONE  # %s\n", prefix, prefix, planeToolControlledClipPlane_names);
          str += tmpStr;
          break;
      case ClipAttributes::Plane1:
          snprintf(tmpStr, 1000, "%splaneToolControlledClipPlane = %sPlane1  # %s\n", prefix, prefix, planeToolControlledClipPlane_names);
          str += tmpStr;
          break;
      case ClipAttributes::Plane2:
          snprintf(tmpStr, 1000, "%splaneToolControlledClipPlane = %sPlane2  # %s\n", prefix, prefix, planeToolControlledClipPlane_names);
          str += tmpStr;
          break;
      case ClipAttributes::Plane3:
          snprintf(tmpStr, 1000, "%splaneToolControlledClipPlane = %sPlane3  # %s\n", prefix, prefix, planeToolControlledClipPlane_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    {   const double *center = atts->GetCenter();
        snprintf(tmpStr, 1000, "%scenter = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", center[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%sradius = %g\n", prefix, atts->GetRadius());
    str += tmpStr;
    if(atts->GetSphereInverse())
        snprintf(tmpStr, 1000, "%ssphereInverse = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%ssphereInverse = 0\n", prefix);
    str += tmpStr;
    if(atts->GetCrinkleClip())
        snprintf(tmpStr, 1000, "%scrinkleClip = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%scrinkleClip = 0\n", prefix);
    str += tmpStr;
    return str;
}

static PyObject *
ClipAttributes_Notify(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_SetQuality(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid quality value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Fast";
        ss << ", Accurate";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the quality in the object.
    obj->data->SetQuality(ClipAttributes::Quality(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetQuality(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetQuality()));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetFuncType(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid funcType value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Plane";
        ss << ", Sphere";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the funcType in the object.
    obj->data->SetFuncType(ClipAttributes::ClipStyle(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetFuncType(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetFuncType()));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane1Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the plane1Status in the object.
    obj->data->SetPlane1Status(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane1Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPlane1Status()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane2Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the plane2Status in the object.
    obj->data->SetPlane2Status(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane2Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPlane2Status()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane3Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the plane3Status in the object.
    obj->data->SetPlane3Status(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane3Status(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPlane3Status()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane1Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane1Origin();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane1Origin in the object as modified.
    obj->data->SelectPlane1Origin();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane1Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane1Origin.
    PyObject *retval = PyTuple_New(3);
    const double *plane1Origin = obj->data->GetPlane1Origin();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane1Origin[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane2Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane2Origin();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane2Origin in the object as modified.
    obj->data->SelectPlane2Origin();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane2Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane2Origin.
    PyObject *retval = PyTuple_New(3);
    const double *plane2Origin = obj->data->GetPlane2Origin();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane2Origin[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane3Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane3Origin();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane3Origin in the object as modified.
    obj->data->SelectPlane3Origin();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane3Origin(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane3Origin.
    PyObject *retval = PyTuple_New(3);
    const double *plane3Origin = obj->data->GetPlane3Origin();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane3Origin[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane1Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane1Normal();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane1Normal in the object as modified.
    obj->data->SelectPlane1Normal();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane1Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane1Normal.
    PyObject *retval = PyTuple_New(3);
    const double *plane1Normal = obj->data->GetPlane1Normal();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane1Normal[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane2Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane2Normal();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane2Normal in the object as modified.
    obj->data->SelectPlane2Normal();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane2Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane2Normal.
    PyObject *retval = PyTuple_New(3);
    const double *plane2Normal = obj->data->GetPlane2Normal();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane2Normal[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlane3Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetPlane3Normal();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the plane3Normal in the object as modified.
    obj->data->SelectPlane3Normal();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlane3Normal(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the plane3Normal.
    PyObject *retval = PyTuple_New(3);
    const double *plane3Normal = obj->data->GetPlane3Normal();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(plane3Normal[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlaneInverse(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the planeInverse in the object.
    obj->data->SetPlaneInverse(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlaneInverse(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPlaneInverse()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetPlaneToolControlledClipPlane(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 4)
    {
        std::stringstream ss;
        ss << "An invalid planeToolControlledClipPlane value was given." << std::endl;
        ss << "Valid values are in the range [0,3]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " None";
        ss << ", Plane1";
        ss << ", Plane2";
        ss << ", Plane3";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the planeToolControlledClipPlane in the object.
    obj->data->SetPlaneToolControlledClipPlane(ClipAttributes::WhichClipPlane(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetPlaneToolControlledClipPlane(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetPlaneToolControlledClipPlane()));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetCenter(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetCenter();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the center in the object as modified.
    obj->data->SelectCenter();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetCenter(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the center.
    PyObject *retval = PyTuple_New(3);
    const double *center = obj->data->GetCenter();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(center[i]));
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetRadius(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the radius in the object.
    obj->data->SetRadius(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetRadius(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetRadius());
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetSphereInverse(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the sphereInverse in the object.
    obj->data->SetSphereInverse(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetSphereInverse(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetSphereInverse()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ClipAttributes_SetCrinkleClip(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the crinkleClip in the object.
    obj->data->SetCrinkleClip(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ClipAttributes_GetCrinkleClip(PyObject *self, PyObject *args)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetCrinkleClip()?1L:0L);
    return retval;
}



PyMethodDef PyClipAttributes_methods[CLIPATTRIBUTES_NMETH] = {
    {"Notify", ClipAttributes_Notify, METH_VARARGS},
    {"SetQuality", ClipAttributes_SetQuality, METH_VARARGS},
    {"GetQuality", ClipAttributes_GetQuality, METH_VARARGS},
    {"SetFuncType", ClipAttributes_SetFuncType, METH_VARARGS},
    {"GetFuncType", ClipAttributes_GetFuncType, METH_VARARGS},
    {"SetPlane1Status", ClipAttributes_SetPlane1Status, METH_VARARGS},
    {"GetPlane1Status", ClipAttributes_GetPlane1Status, METH_VARARGS},
    {"SetPlane2Status", ClipAttributes_SetPlane2Status, METH_VARARGS},
    {"GetPlane2Status", ClipAttributes_GetPlane2Status, METH_VARARGS},
    {"SetPlane3Status", ClipAttributes_SetPlane3Status, METH_VARARGS},
    {"GetPlane3Status", ClipAttributes_GetPlane3Status, METH_VARARGS},
    {"SetPlane1Origin", ClipAttributes_SetPlane1Origin, METH_VARARGS},
    {"GetPlane1Origin", ClipAttributes_GetPlane1Origin, METH_VARARGS},
    {"SetPlane2Origin", ClipAttributes_SetPlane2Origin, METH_VARARGS},
    {"GetPlane2Origin", ClipAttributes_GetPlane2Origin, METH_VARARGS},
    {"SetPlane3Origin", ClipAttributes_SetPlane3Origin, METH_VARARGS},
    {"GetPlane3Origin", ClipAttributes_GetPlane3Origin, METH_VARARGS},
    {"SetPlane1Normal", ClipAttributes_SetPlane1Normal, METH_VARARGS},
    {"GetPlane1Normal", ClipAttributes_GetPlane1Normal, METH_VARARGS},
    {"SetPlane2Normal", ClipAttributes_SetPlane2Normal, METH_VARARGS},
    {"GetPlane2Normal", ClipAttributes_GetPlane2Normal, METH_VARARGS},
    {"SetPlane3Normal", ClipAttributes_SetPlane3Normal, METH_VARARGS},
    {"GetPlane3Normal", ClipAttributes_GetPlane3Normal, METH_VARARGS},
    {"SetPlaneInverse", ClipAttributes_SetPlaneInverse, METH_VARARGS},
    {"GetPlaneInverse", ClipAttributes_GetPlaneInverse, METH_VARARGS},
    {"SetPlaneToolControlledClipPlane", ClipAttributes_SetPlaneToolControlledClipPlane, METH_VARARGS},
    {"GetPlaneToolControlledClipPlane", ClipAttributes_GetPlaneToolControlledClipPlane, METH_VARARGS},
    {"SetCenter", ClipAttributes_SetCenter, METH_VARARGS},
    {"GetCenter", ClipAttributes_GetCenter, METH_VARARGS},
    {"SetRadius", ClipAttributes_SetRadius, METH_VARARGS},
    {"GetRadius", ClipAttributes_GetRadius, METH_VARARGS},
    {"SetSphereInverse", ClipAttributes_SetSphereInverse, METH_VARARGS},
    {"GetSphereInverse", ClipAttributes_GetSphereInverse, METH_VARARGS},
    {"SetCrinkleClip", ClipAttributes_SetCrinkleClip, METH_VARARGS},
    {"GetCrinkleClip", ClipAttributes_GetCrinkleClip, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
ClipAttributes_dealloc(PyObject *v)
{
   ClipAttributesObject *obj = (ClipAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *ClipAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyClipAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "quality") == 0)
        return ClipAttributes_GetQuality(self, NULL);
    if(strcmp(name, "Fast") == 0)
        return PyInt_FromLong(long(ClipAttributes::Fast));
    if(strcmp(name, "Accurate") == 0)
        return PyInt_FromLong(long(ClipAttributes::Accurate));

    if(strcmp(name, "funcType") == 0)
        return ClipAttributes_GetFuncType(self, NULL);
    if(strcmp(name, "Plane") == 0)
        return PyInt_FromLong(long(ClipAttributes::Plane));
    if(strcmp(name, "Sphere") == 0)
        return PyInt_FromLong(long(ClipAttributes::Sphere));

    if(strcmp(name, "plane1Status") == 0)
        return ClipAttributes_GetPlane1Status(self, NULL);
    if(strcmp(name, "plane2Status") == 0)
        return ClipAttributes_GetPlane2Status(self, NULL);
    if(strcmp(name, "plane3Status") == 0)
        return ClipAttributes_GetPlane3Status(self, NULL);
    if(strcmp(name, "plane1Origin") == 0)
        return ClipAttributes_GetPlane1Origin(self, NULL);
    if(strcmp(name, "plane2Origin") == 0)
        return ClipAttributes_GetPlane2Origin(self, NULL);
    if(strcmp(name, "plane3Origin") == 0)
        return ClipAttributes_GetPlane3Origin(self, NULL);
    if(strcmp(name, "plane1Normal") == 0)
        return ClipAttributes_GetPlane1Normal(self, NULL);
    if(strcmp(name, "plane2Normal") == 0)
        return ClipAttributes_GetPlane2Normal(self, NULL);
    if(strcmp(name, "plane3Normal") == 0)
        return ClipAttributes_GetPlane3Normal(self, NULL);
    if(strcmp(name, "planeInverse") == 0)
        return ClipAttributes_GetPlaneInverse(self, NULL);
    if(strcmp(name, "planeToolControlledClipPlane") == 0)
        return ClipAttributes_GetPlaneToolControlledClipPlane(self, NULL);
    if(strcmp(name, "None") == 0)
        return PyInt_FromLong(long(ClipAttributes::None));
    if(strcmp(name, "NONE") == 0)
        return PyInt_FromLong(long(ClipAttributes::None));
    if(strcmp(name, "Plane1") == 0)
        return PyInt_FromLong(long(ClipAttributes::Plane1));
    if(strcmp(name, "Plane2") == 0)
        return PyInt_FromLong(long(ClipAttributes::Plane2));
    if(strcmp(name, "Plane3") == 0)
        return PyInt_FromLong(long(ClipAttributes::Plane3));

    if(strcmp(name, "center") == 0)
        return ClipAttributes_GetCenter(self, NULL);
    if(strcmp(name, "radius") == 0)
        return ClipAttributes_GetRadius(self, NULL);
    if(strcmp(name, "sphereInverse") == 0)
        return ClipAttributes_GetSphereInverse(self, NULL);
    if(strcmp(name, "crinkleClip") == 0)
        return ClipAttributes_GetCrinkleClip(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyClipAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyClipAttributes_methods[i].ml_name),
                PyString_FromString(PyClipAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyClipAttributes_methods, self, name);
}

int
PyClipAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "quality") == 0)
        obj = ClipAttributes_SetQuality(self, args);
    else if(strcmp(name, "funcType") == 0)
        obj = ClipAttributes_SetFuncType(self, args);
    else if(strcmp(name, "plane1Status") == 0)
        obj = ClipAttributes_SetPlane1Status(self, args);
    else if(strcmp(name, "plane2Status") == 0)
        obj = ClipAttributes_SetPlane2Status(self, args);
    else if(strcmp(name, "plane3Status") == 0)
        obj = ClipAttributes_SetPlane3Status(self, args);
    else if(strcmp(name, "plane1Origin") == 0)
        obj = ClipAttributes_SetPlane1Origin(self, args);
    else if(strcmp(name, "plane2Origin") == 0)
        obj = ClipAttributes_SetPlane2Origin(self, args);
    else if(strcmp(name, "plane3Origin") == 0)
        obj = ClipAttributes_SetPlane3Origin(self, args);
    else if(strcmp(name, "plane1Normal") == 0)
        obj = ClipAttributes_SetPlane1Normal(self, args);
    else if(strcmp(name, "plane2Normal") == 0)
        obj = ClipAttributes_SetPlane2Normal(self, args);
    else if(strcmp(name, "plane3Normal") == 0)
        obj = ClipAttributes_SetPlane3Normal(self, args);
    else if(strcmp(name, "planeInverse") == 0)
        obj = ClipAttributes_SetPlaneInverse(self, args);
    else if(strcmp(name, "planeToolControlledClipPlane") == 0)
        obj = ClipAttributes_SetPlaneToolControlledClipPlane(self, args);
    else if(strcmp(name, "center") == 0)
        obj = ClipAttributes_SetCenter(self, args);
    else if(strcmp(name, "radius") == 0)
        obj = ClipAttributes_SetRadius(self, args);
    else if(strcmp(name, "sphereInverse") == 0)
        obj = ClipAttributes_SetSphereInverse(self, args);
    else if(strcmp(name, "crinkleClip") == 0)
        obj = ClipAttributes_SetCrinkleClip(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
ClipAttributes_print(PyObject *v, FILE *fp, int flags)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)v;
    fprintf(fp, "%s", PyClipAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
ClipAttributes_str(PyObject *v)
{
    ClipAttributesObject *obj = (ClipAttributesObject *)v;
    return PyString_FromString(PyClipAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *ClipAttributes_Purpose = "This class contains attributes for the clip operator.";
#else
static char *ClipAttributes_Purpose = "This class contains attributes for the clip operator.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(ClipAttributesType,         \
                  "ClipAttributes",           \
                  ClipAttributesObject,       \
                  ClipAttributes_dealloc,     \
                  ClipAttributes_print,       \
                  PyClipAttributes_getattr,   \
                  PyClipAttributes_setattr,   \
                  ClipAttributes_str,         \
                  ClipAttributes_Purpose,     \
                  ClipAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
ClipAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &ClipAttributesType
         || Py_TYPE(other) != &ClipAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    ClipAttributes *a = ((ClipAttributesObject *)self)->data;
    ClipAttributes *b = ((ClipAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static ClipAttributes *defaultAtts = 0;
static ClipAttributes *currentAtts = 0;

static PyObject *
NewClipAttributes(int useCurrent)
{
    ClipAttributesObject *newObject;
    newObject = PyObject_NEW(ClipAttributesObject, &ClipAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ClipAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ClipAttributes(*defaultAtts);
    else
        newObject->data = new ClipAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapClipAttributes(const ClipAttributes *attr)
{
    ClipAttributesObject *newObject;
    newObject = PyObject_NEW(ClipAttributesObject, &ClipAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (ClipAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
ClipAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewClipAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef ClipAttributesMethods[] = {
    {"ClipAttributes", ClipAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *ClipAttributesObserver = 0;

std::string
PyClipAttributes_GetLogString()
{
    std::string s("ClipAtts = ClipAttributes()\n");
    if(currentAtts != 0)
        s += PyClipAttributes_ToString(currentAtts, "ClipAtts.", true);
    return s;
}

static void
PyClipAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("ClipAtts = ClipAttributes()\n");
        s += PyClipAttributes_ToString(currentAtts, "ClipAtts.", true);
        cb(s);
    }
}

void
PyClipAttributes_StartUp(ClipAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyClipAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(ClipAttributesObserver == 0)
    {
        ClipAttributesObserver = new ObserverToCallback(subj,
            PyClipAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyClipAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete ClipAttributesObserver;
    ClipAttributesObserver = 0;
}

PyMethodDef *
PyClipAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return ClipAttributesMethods;
}

bool
PyClipAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &ClipAttributesType);
}

ClipAttributes *
PyClipAttributes_FromPyObject(PyObject *obj)
{
    ClipAttributesObject *obj2 = (ClipAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyClipAttributes_New()
{
    return NewClipAttributes(0);
}

PyObject *
PyClipAttributes_Wrap(const ClipAttributes *attr)
{
    return WrapClipAttributes(attr);
}

void
PyClipAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    ClipAttributesObject *obj2 = (ClipAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyClipAttributes_SetDefaults(const ClipAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new ClipAttributes(*atts);
}

